<template>
  <!--模板-->
  <el-row :gutter="20" >
    <el-col :span="18">
      <nf-form-tab
        v-form-drag="formMeta"
        :model="model"
        :partModel="model2"
        v-bind="formMeta"
      ></nf-form-tab>
    </el-col>
    <el-col :span="6">
      <div
        v-for="(item, key) in model"
        :key="key"
      >
        {{key}}：<span v-if="Array.isArray(item)">【
          <div v-for="item2 in item" :key="item2">
            &nbsp; &nbsp; {{item2}}
          </div>
          】
        </span>
        <span v-else>{{item}}</span>
      </div>
    </el-col>
  </el-row>
  
</template>

<script lang="ts">
  import { defineComponent, reactive } from 'vue'
  import { createModel, nfFormTab, _formDrag } from '../../../lib/main'

  import _formMeta from './form-card.json'

  export default defineComponent({
    name: 'nf-elp-form-tab',
    directives: {
      formDrag: _formDrag
    },
    components: {
      nfFormTab
    },
    props: {
    },
    setup(props, context) {

      const formMeta = reactive(_formMeta)
      // console.log('读取的 json：', formMeta)
      const { itemMeta } = formMeta
      const { colOrder } = formMeta.formMeta
      const model2 = reactive({})

      // 根据 meta 创建表单的 model
      const model = createModel(itemMeta, colOrder)
      // console.log('model：', model)

      return {
        formMeta,
        model2,
        model
      }
    }
  })
</script>